home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / mousdm.com / MOUSEFNC.C < prev   
Encoding:
C/C++ Source or Header  |  1990-02-03  |  3.9 KB  |  172 lines

  1. /* mousefnc.c */
  2.  
  3. /* mouse functions */
  4.  
  5. /* by James B. Burks (1988) */
  6.  
  7. /* released into the public domain by the author  */
  8.  
  9. #include <stdio.h>
  10. #include <bios.h>
  11. #include <dos.h>
  12.  
  13. #include "mousedef.h"
  14.  
  15. void cmouses(int *m1, int *m2, int *m3, int *m4)
  16.  
  17. {                                              /* begin cmouses */
  18. /*  lowest-level routine.  Calls the Microsoft-compatible mouse driver
  19.     directly using the Turbo-C Int86 routine to call INT 33.
  20. */
  21.  
  22. union REGS regs;
  23.  
  24. regs.x.ax = *m1;
  25. regs.x.bx = *m2;
  26. regs.x.cx = *m3;
  27. regs.x.dx = *m4;
  28.  
  29. int86(0x33, ®s, ®s);
  30.  
  31. *m1 = regs.x.ax;
  32. *m2 = regs.x.bx;
  33. *m3 = regs.x.cx;
  34. *m4 = regs.x.dx;
  35.  
  36. }                                               /* end cmouses */
  37.  
  38.  
  39. int m_reset(void)
  40.  
  41. {                                              /* begin m_reset*/
  42.  
  43. /* this routine initializes the mouse driver (if present)
  44.     and returns the number of buttons (0 if no mouse driver).
  45.     It should be called after any change of video mode number.
  46. */
  47.  
  48. int m1 = 0 , m2, m3, m4;
  49.  
  50. cmouses(&m1, &m2, &m3, &m4);
  51.  
  52. if (m1 == -1)
  53.     return(m2);
  54. else
  55.     return(0);
  56.  
  57. }                                              /* end m_reset */
  58.  
  59.  
  60. void m_show_cursor(void)
  61.  
  62. {                                             /* begin m_show_cursor */
  63.  
  64. /*  function which instructs the mouse driver to show the mouse cursor
  65.     and track the mouse motion. If multiple calls to m_hide_cursor
  66.     are done, you must make multiple calls to m_show_cursor.
  67. */
  68.  
  69. int m1 = 1, m2, m3, m4;
  70.  
  71. cmouses(&m1, &m2, &m3, &m4);
  72.  
  73. }                                             /* end m_show_cursor */
  74.  
  75.  
  76. void m_hide_cursor(void)
  77.  
  78. {                                            /* begin m_hide_cursor */
  79.  
  80. /* removes the mouse cursor from the screen.  */
  81.  
  82. int m1 = 2, m2, m3, m4;
  83.  
  84. cmouses(&m1, &m2, &m3, &m4);
  85.  
  86. }                                            /* end m_hide_cursor */
  87.  
  88.  
  89. int m_status(int *ix, int *iy)
  90.  
  91. {                                           /* begin m_status */
  92.  
  93. /*  function which returns the button status as value, and the current
  94.     x/y position as arguments.
  95. */
  96.  
  97. int m1 = 3, m2;
  98.  
  99. cmouses(&m1, &m2, ix, iy );
  100.  
  101. return(m2);
  102.  
  103. }                                           /* end m_status */
  104.  
  105.  
  106. int m_release(int bs, int *ix, int *iy)
  107.  
  108. {                                          /* begin m_release */
  109.  
  110. /* function which returns the number of button releases since the
  111.     last call to m_release.  The x/y position of the last button
  112.     press are also returned.
  113. */
  114.  
  115. int m1 = 6, m2 = bs;
  116.  
  117. cmouses(&m1,&m2, ix, iy);
  118.  
  119. return(m2);
  120.  
  121. }                                          /* end m_release */
  122.  
  123. void m_graphics_cursor( int *graph_ptr)
  124.  
  125. {                                          /* begin m_grahpics_cursor */
  126.  
  127. /*  This function allows you to change the shape of the mouse cursor
  128.     in graphics mode.  You cannot change the text mode cursor.
  129. */
  130.  
  131. int m1 = 9, m2 = -1, m3 = -1;
  132.  
  133. cmouses(&m1, &m2, &m3, graph_ptr);
  134.  
  135. }                                          /* end m_grahpics_cursor */
  136.  
  137.  
  138. void m_cursor_set(int *ix, int *iy)
  139.  
  140. {                                           /* begin m_cursor_set */
  141.  
  142. /*  allows the program to reset the current cursor position both on the
  143.     screen and in the mouse driver.  Note: It does not physically
  144.     move the mouse.
  145. */
  146.  
  147. int m1 = 4, m2;
  148.  
  149. cmouses(&m1, &m2, ix, iy );
  150.  
  151. }                                           /* end m_cursor_set */
  152.  
  153. void m_region(int hmin, int hmax, int vmin, int vmax)
  154.  
  155. {                                           /* begin m_region */
  156.  
  157. /*  allows you to restrict the mouse motion to a given rectangular region
  158.     on the screen.
  159. */
  160.  
  161. int m1 =7, m2;
  162.  
  163. cmouses(&m1,&m2, &hmin, &hmax); /* sets min/max horizontal mouse position */
  164.  
  165. m1 = 8;
  166.  
  167. cmouses(&m1, &m2, &vmin, &vmax); /* sets min/max vertical mouse position */
  168.  
  169. }                                           /* end m_region */
  170.  
  171. /*  eof mousefnc.c  */
  172.